package com.example.feign;

import com.example.constant.ServiceConstant;
import com.example.constant.ServicePrefixConstant;
import com.example.dto.BusinessUserDTO;
import com.example.dto.SysUserDTO;
import com.example.feign.fallback.UsernameFeignClientFallbackFactory;
import com.example.model.api.Result;
import com.example.security.UserDetail;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 用户接口
 *
 * @author Mark sunlightcs@gmail.com
 */
//@FeignClient(name = ServiceConstant.ADMIN_SERVER, contextId = "StorageFeignClient", configuration = FeignConfig.class, fallbackFactory = StorageFeignClientFallbackFactory.class)
@FeignClient(name = ServiceConstant.ADMIN_SERVER, contextId = "UsernameFeignClient", fallbackFactory = UsernameFeignClientFallbackFactory.class)
public interface UsernameFeignClient {

    @GetMapping(ServicePrefixConstant.ADMIN_SERVER + "/username/{username}")
    Result<UserDetail> getByUsername(@PathVariable("username") String username);

    @GetMapping(ServicePrefixConstant.ADMIN_SERVER + "/businessusername/{username}")
    Result<UserDetail> getByBusinessUsername(@PathVariable("username") String username);

    @GetMapping(ServicePrefixConstant.ADMIN_SERVER + "/businessusername/isBusiness/{id}")
    Result<Integer> getIsBusiness(@PathVariable("id") String id);

    @GetMapping(ServicePrefixConstant.ADMIN_SERVER + "/businessusername/exist/{openid}")
    Result<BusinessUserDTO> businessUsernameExist(@PathVariable("openid") String openid);

    @PostMapping(ServicePrefixConstant.ADMIN_SERVER + "/businessusername/create")
    Result<String> createBusinessUser(@RequestBody BusinessUserDTO businessUserDTO);

    @GetMapping(ServicePrefixConstant.ADMIN_SERVER + "/username/sysusername/{username}")
    Result<SysUserDTO> getSysUsername(@PathVariable("username") String username);

    @PostMapping(ServicePrefixConstant.ADMIN_SERVER + "/username/thirdOauth2username")
    Result saveThirdOauth2(@RequestBody SysUserDTO dto);
}